package cn.b.sky.form.model;

import cn.b.sky.common.model.ImeCommon;

import java.util.List;

/**
 * 
 * <strong>Title : BusinessField.java<br></strong>
 * <strong>Package : cn.b.sky.flowable.model<br></strong>
 * <strong>Description : </strong>业务字段对象<br> 
 * <strong>Create on : 2016-09-27 下午07:13:36<br></strong>
 * <p>
 * @author JunLin.Yang<br>
 * @version <strong>v1.0.0</strong><br>
 */
public class BusinessField extends ImeCommon {

  /**
   * 数据库字段
   */
  private String dbField;

  /**
   * 小数位数
   */
  private Integer scale;

  /**
   * 业务类型
   */
  private String businessType;

  /**
   * 最小值
   */
  private String minimumValue;
	
	/**
	 * 默认值
	 */
	private String defaultValue;
	
	/**
	 * 校验规则{required,email,...}逗号隔开
	 */
	private String validationExpression;
	
	/**
	 * 系统内置字段标志
	 */
	private Integer systemFieldFlag = 0;
	
	/**
	 * 最大值
	 */
	private String maximumValue;
	
	/**
	 * 字段标签
	 */
	private String fieldLabel;
	
	/**
	 * 数据类型
	 */
	private String dataType;
	
	/**
	 * 数据类型描述文本
	 */
	private String dataTypeText;
	
	/**
	 * 字段类型
	 */
	private String fieldType;
	
	/**
	 * 字段类型描述文本
	 */
	private String fieldTypeText;
	
	/**
	 * 选项值查询语句
	 */
	private String querySql;
	
	/**
	 * 业务字段
	 */
	private String businessField;
	
	/**
	 * 字段描述
	 */
	private String fieldDescription;
	
	/**
	 * 必填标志
	 */
	private Integer requiredFlag = 0;
	
	/**
	 * 长度
	 */
	private Integer length;
	
	private Integer checkedFlag;//选中标记，自定义查询使用
	
	/**
	 * 字段选项值集合
	 */
	private List<BusinessFieldValue> businessFieldValueList ;
	
	/**
	 * 附件集合
	 */
	private List<BusinessAttachment> attachments;

	
  public String getDbField() {
    return dbField;
  }

  public void setDbField(String dbField) {
    this.dbField = dbField;
  }

  public Integer getScale() {
    return scale;
  }

  public void setScale(Integer scale) {
    this.scale = scale;
  }

  public String getBusinessType() {
    return businessType;
  }

  public void setBusinessType(String businessType) {
    this.businessType = businessType;
  }

  public String getMinimumValue() {
    return minimumValue;
  }

  public void setMinimumValue(String minimumValue) {
    this.minimumValue = minimumValue;
  }

  public String getDefaultValue() {
    return defaultValue == null ? "" : defaultValue;
  }

  public void setDefaultValue(String defaultValue) {
    this.defaultValue = defaultValue;
  }

  public String getValidationExpression() {
    return validationExpression;
  }

  public void setValidationExpression(String validationExpression) {
    this.validationExpression = validationExpression;
  }

  public Integer getSystemFieldFlag() {
    return systemFieldFlag;
  }

  public void setSystemFieldFlag(Integer systemFieldFlag) {
    this.systemFieldFlag = systemFieldFlag;
  }

  public String getMaximumValue() {
    return maximumValue;
  }

  public void setMaximumValue(String maximumValue) {
    this.maximumValue = maximumValue;
  }

  public String getFieldLabel() {
    return fieldLabel;
  }

  public void setFieldLabel(String fieldLabel) {
    this.fieldLabel = fieldLabel;
  }

  public String getDataType() {
    return dataType;
  }

  public void setDataType(String dataType) {
    this.dataType = dataType;
  }

  public String getDataTypeText() {
    return dataTypeText;
  }

  public void setDataTypeText(String dataTypeText) {
    this.dataTypeText = dataTypeText;
  }

  public String getFieldType() {
    return fieldType;
  }

  public void setFieldType(String fieldType) {
    this.fieldType = fieldType;
  }

  public String getFieldTypeText() {
    return fieldTypeText;
  }

  public void setFieldTypeText(String fieldTypeText) {
    this.fieldTypeText = fieldTypeText;
  }

  public String getQuerySql() {
    return querySql;
  }

  public void setQuerySql(String querySql) {
    this.querySql = querySql;
  }

  public String getBusinessField() {
    return businessField;
  }

  public void setBusinessField(String businessField) {
    this.businessField = businessField;
  }

  public String getFieldDescription() {
    return fieldDescription;
  }

  public void setFieldDescription(String fieldDescription) {
    this.fieldDescription = fieldDescription;
  }

  public Integer getRequiredFlag() {
    return requiredFlag;
  }

  public void setRequiredFlag(Integer requiredFlag) {
    this.requiredFlag = requiredFlag;
  }

  public Integer getLength() {
    return length;
  }

  public void setLength(Integer length) {
    this.length = length;
  }

  public List<BusinessFieldValue> getBusinessFieldValueList() {
    return businessFieldValueList;
  }

  public void setBusinessFieldValueList(List<BusinessFieldValue> businessFieldValueList) {
    this.businessFieldValueList = businessFieldValueList;
  }

  public void preProcessingToStore(){
    this.businessType = this.businessType.toUpperCase();
    this.businessField = this.businessField.toUpperCase();
    this.dbField = this.dbField.toUpperCase();
  }
  
  public Integer getCheckedFlag() {
    return checkedFlag;
  }

  public void setCheckedFlag(Integer checkedFlag) {
    this.checkedFlag = checkedFlag;
  }

  
  public List<BusinessAttachment> getAttachments() {
    return attachments;
  }

  public void setAttachments(List<BusinessAttachment> attachments) {
    this.attachments = attachments;
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((dbField == null) ? 0 : dbField.hashCode());
    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj instanceof BusinessField) {
      BusinessField bField = (BusinessField) obj;
      if (dbField==null||bField.getDbField()==null) {
        return false;
      }
      return dbField.toUpperCase().equals(bField.getDbField().toUpperCase());
    }
    return super.equals(obj);
  }
}